package com.zhuimeng.Application.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zhuimeng.Application.dao.HappyBeanHistoryDao;
import com.zhuimeng.Application.entity.HappyBeanHistory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class HappyBeanHistoryServicrImpl implements IHappyBeanHistoryService {

    @Autowired
    private HappyBeanHistoryDao happyBeanHistoryDao;

    @Override
    public int insertHistory(HappyBeanHistory happyBeanHistory) {
        return happyBeanHistoryDao.insert(happyBeanHistory);
    }

    @Override
    public List<HappyBeanHistory> queryHistoryByUid(Integer uid) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("u_id", uid);
        queryWrapper.orderByDesc("create_time");
        return happyBeanHistoryDao.selectList(queryWrapper);
    }
}
